/**
 * @file ASMGen.hpp
 * @author Shenghua Lin, Minmin Gong, Luca Barbieri
 *
 * @section DESCRIPTION
 *
 * This source file is part of KlayGE
 * For the latest info, see http://www.klayge.org
 *
 * @section LICENSE
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published
 * by the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 * You may alternatively use this source under the terms of
 * the KlayGE Proprietary License (KPL). You can obtained such a license
 * from http://www.klayge.org/licensing/.
 */

#ifndef _DXBC2GLSL_ASMGEN_HPP
#define _DXBC2GLSL_ASMGEN_HPP

#pragma once

#include <DXBC2GLSL/Shader.hpp>

class ASMGen
{
public:
	explicit ASMGen(std::shared_ptr<ShaderProgram> const & program);

	void ToASM(std::ostream& out);

private:
	void Disasm(std::ostream& out, ShaderOperand const & op, ShaderImmType imm_type);
	void Disasm(std::ostream& out, ShaderInstruction const & op);
	void Disasm(std::ostream& out, ShaderDecl const & op);
	void Disasm(std::ostream& out, std::vector<DXBCSignatureParamDesc> const & signature, uint32_t fourcc);
	void Disasm(std::ostream& out, std::vector<DXBCConstantBuffer> const & cb);
	void Disasm(std::ostream& out, std::vector<DXBCInputBindDesc> const & bindings);
	// Disasm cb default value
	void Disasm(std::ostream& out, DXBCShaderVariable const & var);
	void Disasm(std::ostream& out, DXBCShaderVariable const & var, uint32_t offset);
	void Disasm(std::ostream& out, const char* value, ShaderVariableType type);

private:
	std::shared_ptr<ShaderProgram> program_;
};

#endif		// _DXBC2GLSL_ASMGEN_HPP
